package com.tarena.lbs.coupon.enums;

import lombok.Getter;

/**
 * @author: 
 * @date: 2025/10/11
 * @Version: 1.0
 * @description: 优惠券领取渠道枚举
 */
@Getter
public enum CouponIssueChannel {
    /**
     * 线下门店领取
     */
    OFFLINE_STORE(0, "线下门店"),

    /**
     * 微信公众号
     */
    WECHAT_OFFICIAL_ACCOUNT(1, "微信公众号"),

    /**
     * APP内领取
     */
    MOBILE_APP(2, "手机APP"),

    /**
     * PC网站
     */
    WEBSITE(3, "PC网站"),

    /**
     * 小程序
     */
    WEIXING_MINI_PROGRAM(4, "微信小程序"),

    /**
     * H5页面
     */
    H5_PAGE(5, "H5页面"),

    /**
     * 系统自动发放
     */
    SYSTEM_AUTO(10, "系统自动发放"),

    /**
     * 兑换码兑换
     */
    REDEEM_CODE(11, "兑换码"),

    /**
     * 预留字段：用于未来扩展
     */
    RESERVED_1(100, "预留渠道1"),

    /**
     * 预留字段：用于未来扩展
     */
    RESERVED_2(101, "预留渠道2"),

    /**
     * 预留字段：用于未来扩展
     */
    RESERVED_3(102, "预留渠道3");

    private final Integer code;
    private final String description;

    CouponIssueChannel(Integer code, String description) {
        this.code = code;
        this.description = description;
    }

    /**
     * 根据code获取领取渠道枚举
     *
     * @param code 渠道编码
     * @return 领取渠道枚举
     */
    public static CouponIssueChannel fromCode(Integer code) {
        for (CouponIssueChannel channel : values()) {
            if (channel.getCode().equals(code)) {
                return channel;
            }
        }
        throw new IllegalArgumentException("Unknown coupon issue channel code: " + code);
    }
}